
Entity	=	function (mesh)
{
	/************************************/
	/*			Properties				*/	
	/************************************/
	
	this.m_Transform;    	/*!< The Transform object is used to determine the Entity position and rotation in Space	*/

	this.m_GLSLProgram;  	/*!< Id of a valid GLSL program compiled                    */
	this.m_Name;         	/*!< Name of the Entity Object                              */
	this.m_Mesh;         	/*!< Mesh linked to the Entity object     					*/
	this.m_View;			/*!< View linked to current Mesh
	
	/************************************/
	/*			Constructor				*/	
	/************************************/
	
	this.m_Mesh 	= 	mesh;

	
	this.m_Transform = new Transform();

}

    /********************************/
    /*          Members             */
    /********************************/

        /********************************/
        /*          Methods		        */
        /********************************/
		
			Entity.prototype.AddView	=	function(view)
			{
				this.m_View = view;
				this.m_View.m_Entity=this;
				this.m_Transform.m_View = 1;
			}
			
			Entity.prototype.Update= function()
			{
				this.Display();
			}
			
			Entity.prototype.Display	=	function()
			{
                if(this.m_Mesh!=undefined)
                {
                    this.m_GLSLProgram.Use();
					BufferObject.BindIBO();
					BufferObject.BindVBO();
					gl.activeTexture(gl.TEXTURE0);
					gl.bindTexture(gl.TEXTURE_2D, g_Image.m_Texture);
					gl.uniform1i(this.m_GLSLProgram.m_Uniforms[3], 0);
					
					var temp = this.m_Transform.m_TransformMatrix.MultMatrix(View.Default.m_ProjectionMatrix);
					temp = temp.MultMatrix(View.Default.m_ViewMatrix);
					
					var Identitylol = new Array(1,0,0,0.5, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);

					gl.uniformMatrix4fv(this.m_GLSLProgram.m_Uniforms[0], false, new Float32Array( this.m_Transform.m_TransformMatrix.AsArray()));
					gl.uniformMatrix4fv(this.m_GLSLProgram.m_Uniforms[1], false, new Float32Array(View.Default.m_ViewMatrix.AsArray()));
					gl.uniformMatrix4fv(this.m_GLSLProgram.m_Uniforms[2], false, new Float32Array(View.Default.m_ProjectionMatrix.AsArray()));
					this.m_Mesh.Display();
                }
			}
			
	/********************************/
    /*          Static             */
    /********************************/

		/********************************/
        /*          Properties		    */
        /********************************/
			
            Entity.Last;           /*!< Last Entity inside the Entities container	*/
            Entity.First;          /*!< First Entity inside the Entities container	*/
			
            Entity.Entities= new Array();	/*!< Store all scene Entites created using the static method "New"	*/
			
		/********************************/
        /*          Methods		        */
        /********************************/
		
			Entity.New = function(mesh)
			{
				var entity = new Entity();
				entity.m_Mesh = mesh;
				Entity.Entities.push(entity);
				return entity;
			}


			Entity.First = function()
			{
				return Entity.Entities[0];
			}

			Entity.Last = function()
			{
				return Entity.Entities[Entity.Entities.length-1];
			}
			
	